import React from 'react'
import { createBrowserRouter,RouteObject } from 'react-router-dom'
import RequireAuth from '@/utils/RequireAuth'

const Home = React.lazy(()=>import('../page/home'));
const Login = React.lazy(()=>import('../page/login'));
const NotFound = React.lazy(()=>import('../page/404'));


// const router = createBrowserRouter([
//     {
//         path:'/',
//         // redirect:'/login',
//         element:<RequireAuth allowed={true} redirectTo="/login"><Home/></RequireAuth>
//     },
//     {
//         path:'/login',
//         element:<RequireAuth allowed={false} redirectTo="/"><Login/></RequireAuth>
//     },
//     // {
//     //     path:'/home',
//     //     element:<RequireAuth allowed={true} redirectTo="/login"><Home/></RequireAuth>
//     // },
//     {
//         path:'*',
//         element:<NotFound/>
//     }
// ])

// 静态的路由
export const  staticRoutes:RouteObject[]=[
    {
        path:'/',
        // redirect:'/login',
        element:<RequireAuth allowed={true} redirectTo="/login"><Home/></RequireAuth>
    },
    {
        path:'/login',
        element:<RequireAuth allowed={false} redirectTo="/"><Login/></RequireAuth>
    },
    // {
    //     path:'/home',
    //     element:<RequireAuth allowed={true} redirectTo="/login"><Home/></RequireAuth>
    // },
    {
        path:'*',
        element:<NotFound/>
    }
]
